﻿using MongoDB.Driver;
using Sustainalytics.Entities.RiskRatings;
using System.Collections.Generic;

namespace Sustainalytics.ScreeningTool.Synchronization.Handlers.RiskRatings
{
    public class ResearchProfileHandler<T> where T : RiskRatingResearchProfileBase
    {
        public virtual ProjectionDefinition<T> GetProjection(ProjectionDefinitionBuilder<T> builder) => builder
            .Include(x => x.ManagementRisk)
            .Include(x => x.Assessment)
            .Include(x => x.ManagementCluster)
            .Include(x => x.ExposureCluster)
            .Include(x => x.LastUpdate)
            .Include(x => x.BusinessModelComment)
            .Include(x => x.AnalystViewOverallAssessment)
            .Include(x => x.OverallExposureAssessment)
            .Include(x => x.OverallManagementAssessment)
            .Include(x => x.ExposureComment)
            .Include(x => x.EsgRiskManagementComment)
            .Include(x => x.AnalystViewOverallConsolidated);

        public virtual IEnumerable<ExtraElement> GetExtraElements(T entity)
        {
            var managementRisk = entity.ManagementRisk;
            return new ExtraElementList
            {
                { "ESG Risk Score",                  managementRisk.UnmanagedRisk    },
                { "Overall Management Score",        managementRisk.Management       },
                { "Overall Exposure Score",          managementRisk.Exposure         },
                { "Overall Manageable Risk Score",   managementRisk.ManageableRisk   },
                { "Overall Unmanageable Risk Score", managementRisk.UnmanageableRisk },
                { "Overall Managed Risk Score",      managementRisk.ManagedRisk      },
                { "Overall Management Gap Score",    managementRisk.ManagementGap    },

                { "ESG Risk Category",               entity.Assessment               },
                { "Overall Management Category",     entity.ManagementCluster        },
                { "Overall Exposure Category",       entity.ExposureCluster          },
                { "Last publishing date",            entity.LastUpdate               },

                { "Analyst View - Business Model",                entity.BusinessModelComment           },
                { "Analyst View - Overall Assessment",            entity.AnalystViewOverallAssessment   },
                { "Analyst View - Overall Exposure Assessment",   entity.OverallExposureAssessment      },
                { "Analyst View - Overall Management Assessment", entity.OverallManagementAssessment    },
                { "Analyst View - Overall Exposure Narrative",    entity.ExposureComment                },
                { "Analyst View - Overall Management Narrative",  entity.EsgRiskManagementComment       },
                { "Analyst View - Overall - Consolidated",        entity.AnalystViewOverallConsolidated },
            };
        }
    }
}
